<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Vue Router Demo</title>
    <script src="../../../js/vue.js"></script>
    <script src="../../../js/vue-router.js"></script>
    <style>
        .active {
            color: red;
        }
        .slide-fade-enter-active, .slide-fade-leave-active {
            transition: all 0.5s ease;
        }
        .slide-fade-enter, .slide-fade-leave-to {
            opacity: 0;
            transform: translateX(200%);
        }
        .slide-fade-enter-to, .slide-fade-leave {
            opacity: 1;
            transform: translateX(0);
        }
    </style>
</head>
<body>
    <div id="app">
        <h1>{{ message }}</h1>
        <p>
            <router-link to="/user/59">期末分数</router-link>
            <router-link to="/user/200">改它！</router-link>
        </p>
        <transition name="slide-fade">
            <router-view></router-view>
        </transition>
    </div>
    
    <script>
    // 用户组件
    var User = {
        template: `
            <div>
                <h2>张三期末分数： {{ $route.params.id }}</h2>
            </div>
        `
    };
    
    // 实例化路由
    var router = new VueRouter({
        routes: [
            {
                path: '/user/:id', // 动态路由参数
                component: User
            }
        ]
    });
    
    // 实例化 Vue
    var vm = new Vue({
        el: '#app',
        router: router,
        data: {
            message: '教务系统后台期末分数管理系统'
        }
    });
    </script>
</body>
</html>